//== SAGITTARIUS ============================================================================

//== FILEDOC =========================================================================

/** @file module.h
  * @brief module
  */

//== BEGINNING OF CODE ===============================================================

#ifndef __SAGUTTARUIS__MODULE__H_
#define __SAGUTTARUIS__MODULE__H_

//== INCLUDES ========================================================================

#include "sagittarius/core/SagittariusCore.h"
#include "sagittarius/symtab/symtab.h"
#include "sagittarius/types/types.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    SG_TYPE_PARAMS;
} sg_mod_type;

typedef struct __compiledSrc compiledSrc;

typedef struct {
    SG_VAL_PARAMS
    /// Initialized?
    int live;
    /// Initialization fun
    void (*load_mod)(sg_value*);
    /// Release fun
    void (*unload_mod)(sg_value*);
    /// Symbol (the name)
    symcode s;
    /// Object
    sg_value* o;
    /// LLVM value representing symbol instance (sg_symbol_inst)
    void* syminst;
    /// Symbol table
    symtab* st;
    /// Source (not for built-in modules)
    compiledSrc* src;
} sg_module;

sg_module* sg_cast_module(sg_value* v);

sg_module* sg_create_module();

void sg_release_module(sg_module* m);

#ifdef __cplusplus
}//extern "C"
#endif

#endif
